﻿using BLL;
using Model;

/// <summary>
///CommHelper 的摘要说明
/// </summary>
public static class CommHelper
{
    private static PackageProduct pp = new PackageProduct();

    /// <summary>
    /// 判断采集的序列号，是否合法的可录入数据库的SN
    /// 1.符合编码规则的腔体序列号
    /// 2.已有关联数据的成品序列号
    /// </summary>
    /// <param name="sn"></param>
    /// <returns>合法可录入数据库则为true</returns>
    public static bool IsValidSN_forDataAcquisition(string sn)
    {
        if (pp.IsFormated_ProductSN(sn) || pp.HasUnionData_PackageProductSN(sn))
            return true;
        return false;
    }

    /// <summary>
    /// 无论用户的输入是腔体序列号，还是成品序列号，都返回腔体序列号
    /// </summary>
    /// <param name="productSN"></param>
    /// <returns></returns>
    public static string GetProductSN(string sn)
    {
        PackageProductInfo ppi = pp.GetPackageProductbyPackageProductSN(sn);
        if (!string.IsNullOrEmpty(ppi.ProductSN))
            sn = ppi.ProductSN;
        return sn;
    }
}
